/*
 * @Author      : ZhouQiJun
 * @Date        : 2025-08-05 02:14:07
 * @LastEditors : ZhouQiJun
 * @LastEditTime: 2025-08-05 02:42:54
 * @Description : vite 配置
 */
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'

const KB = 1024
// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), vueJsx(), vueDevTools()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
  build: {
    rollupOptions: {
      output: {
        entryFileNames: 'app-[hash].js',
        chunkFileNames: 'js/[name]-[hash].js',
        assetFileNames: '[ext]/[name]-[hash].[ext]',
        // 分割出来的(异步代码) js 小于 5KB, 合并
        experimentalMinChunkSize: 5 * KB,
      },
      //external: ['vue', 'vue-router', 'pinia'],
    },
    // 小于 4KB, 转成 base64 进入代码
    assetsInlineLimit: 0, // 10 * KB,
  },
})
